package com.example.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.base.BaseController;
import com.example.model.User;
import com.example.service.UserServer;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
public class UserController extends BaseController{

	@Autowired
	UserServer userServer;
	
	@ApiOperation(value="value1", notes="notes1")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
    })
	@RequestMapping(value = "/findAll",method= RequestMethod.POST)
	@ResponseBody
	public List<User> findAll(){
		return userServer.findAll();
	}
	
	@ApiOperation(value="value2", notes="notes2")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
    })
	@RequestMapping(value = "/findById",method= RequestMethod.POST)
	@ResponseBody
	public User findAll(Integer id){
		return userServer.selectByPrimaryKey(id);
	}
	
	@ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象，并根据传过来的user信息来更新用户详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
    })
	@RequestMapping(value = "/test",method= RequestMethod.POST)
	@ResponseBody
	public String test(){
		
		return "SUCCESS";
	}
	
}
